package com.tron.dobest.java.tronserializable;

import org.apache.commons.lang3.SerializationUtils;

import java.io.*;

public class Start {
    public static void main(String[] args) throws IOException {
        TronSerializableData data = new TronSerializableData();
        data.setA("字符串");
        data.setB(10);

        serializableObject(data);
        print();

    }

    private static void print() throws FileNotFoundException {
        TronSerializableData data;
        Object o = SerializationUtils.deserialize(new FileInputStream(new File("src/main/java/com/tron/dobest/java/tronserializable/data.txt")));
        data = (TronSerializableData) o;
        System.out.println(data);
    }

    private static void serializableObject(TronSerializableData data) throws FileNotFoundException {
        SerializationUtils.serialize(data, new FileOutputStream(new File("src/main/java/com/tron/dobest/java/tronserializable/data.txt")));
    }
}
